$(document).ready(function () {
    jQuery.validator.addMethod("lettersonly", function (value, element) {
        return this.optional(element) || /^[a-z0-9_-]+$/i.test(value);
    }, "Please use only a-z0-9_-");
    $('#form-signin').validate({
        rules: {
            login: {
                minlength: 3,
                maxlength: 15,
                required: true,
                lettersonly: true
            },
            password: {
                minlength: 3,
                maxlength: 15,
                required: true,
                lettersonly: true
            },
        },
        highlight: function (element) {
            $(element).closest('.control-group').addClass('has-error');

            $("#button-lock").show();
            $("#button-login").hide();
        },
        unhighlight: function (element) {
            $(element).closest('.control-group').removeClass('has-error');

            /* Hidden button login */
            var inputlogin = document.getElementById("login").value.length;
            ;
            var inputlock = document.getElementById("password").value.length;
            ;

            if (inputlogin >= 3 && inputlock >= 3)
            {
                $("#button-lock").hide();
                $("#button-login").show();
            }
        }
    });
});
